package org.goldfish.cookied_chatroom02.model;

import jakarta.servlet.ServletContext;
import jakarta.servlet.http.HttpServletRequest;
import org.goldfish.cookied_chatroom02.entity.DetailBean;
import org.goldfish.cookied_chatroom02.entity.PreviewBean;

import java.io.InputStream;
import java.util.List;
import java.util.Map;

public interface ChatRoomManager extends LoginParams, ChatRoomParams {
    /**
     * check if the request is from login page<br/>
     * <strong>use only when login status is confirmed</strong>
     * @param request
     * @return {@code false} if this request brings message to send<br/>
     *          {@code true} if this request is from login page<br/>
     *          {@code null} if the method cannot be known
     */
    Boolean isFromLogin(HttpServletRequest request,Map<String,String> formContentMap);

    boolean validSession(HttpServletRequest request, ServletContext context);

    List<PreviewBean> getPreviews(HttpServletRequest request);

    Map<String, Integer> availableReceivers(HttpServletRequest request);

    /**
     * read the message type from the request,<br/>
     * and return the corresponding message type<br/>
     * @param request the request to read from
     * @return the message type
     */
    MessageType getMessageType(HttpServletRequest request);

    boolean sendMessages(HttpServletRequest request,Map<String,String> formMap);

    List<DetailBean> getDetails(HttpServletRequest request);

    enum MessageType {
        SUMMARIES,
        DETAILS
    }
}
